package com.thinkgem.jeesite.cn.yy.listener;

import com.thinkgem.jeesite.cn.yy.utils.MD5Util;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class ReaderCutPageListener implements ServletContextListener{

	@Override
	public void contextInitialized(ServletContextEvent event) {
		 
		 try
		 {
			Properties pp=new Properties();
			 InputStream inStream = MD5Util.class.getClassLoader().getResourceAsStream("jeesite.properties");
			 pp.load(inStream);
			 int currentPage=Integer.parseInt(pp.getProperty("currentPage","1"));
			 int pageSize=Integer.parseInt(pp.getProperty("pageSize","5"));
			 ServletContext app=event.getServletContext();
			 app.setAttribute("currentPage", currentPage);
			 app.setAttribute("pageSize", pageSize);
		 } catch (IOException e) {
			e.printStackTrace();
		}
	}

	@Override
	public void contextDestroyed(ServletContextEvent sce) {
		// TODO Auto-generated method stub
		
	}

}
